package kyssion.leetcode.num201_250;

import kyssion.leetcode.util.ListNode;
import kyssion.leetcode.util.ShowUtil;

public class code203_移除链表元素 {
    public static void main(String[] args) {
        ListNode listNode = ListNode.createListNode(
                new int[]{

                }
        );
        listNode = new code203_移除链表元素().removeElements(
                listNode , 1
        );
        ShowUtil.showNode(listNode);
    }
    public ListNode removeElements(ListNode head, int val) {
        ListNode before = new ListNode(-1);
        before.next = head;
        ListNode item = before;
        while (head != null) {
            if (head.val == val) {
                item.next = head.next;
            }else{
                item = item.next;
            }
            head = head.next;
        }
        return before.next;
    }
}
